package com.example.springbott.controller;

import com.example.springbott.aspactJ.OperationName;
import com.example.springbott.bean.BaseRespVo;



import com.example.springbott.bean.common.*;
import com.example.springbott.service.AdminConfigService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 1784549954@qq.com
 * @since 2022/11/20 16:10
 */
@RequestMapping("admin")
@RestController
public class AdminConfigController {

    @Autowired
    AdminConfigService adminConfigService;

    //------------------------------heheer--------------------------------------

    /**
     * 接口：http://182.92.235.201:8083/admin/dashboard
     * 首页
     *
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/20 10:10
     */

    @RequestMapping("dashboard")
    @OperationName("1")
    public BaseRespVo dashboard() {

        //查询四张表 goods user goods_product order
        DashboardVO dashboardVO = adminConfigService.dashboard();
        return BaseRespVo.ok(dashboardVO);
    }


    /**
     * http://182.92.235.201:8083/admin/config/mall
     * 商场配置
     *
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/20 10:33
     */
    @RequiresPermissions("admin:config:mall:list")
    @GetMapping("config/mall")
    @OperationName("1")
    public BaseRespVo configMall() {
        ConfigMallVO configMallVO = adminConfigService.configMall();
        return BaseRespVo.ok(configMallVO);

    }

    /**
     * http://182.92.235.201:8083/admin/config/mall
     * 商场配置
     *
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/20 10:33
     */
    @RequiresPermissions("admin:config:mall:updateConfigs")
    @PostMapping("config/mall")
    @OperationName("1")
    public BaseRespVo configMallPost(@RequestBody ConfigMallVO configMall) throws IllegalAccessException {
        adminConfigService.configMallPost(configMall);
        return BaseRespVo.ok(null);
    }


    /**
     * http://182.92.235.201:8083/admin/config/express
     * 运费配置
     *
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/20 13:11
     */
    @RequiresPermissions("admin:config:express:list")
    @GetMapping("config/express")
    @OperationName("1")
    public BaseRespVo configExpress() {
        ConfigExpressVO expressVO = adminConfigService.configExpress();
        return BaseRespVo.ok(expressVO);
    }

    @RequiresPermissions("admin:config:express:updateConfigs")
    @PostMapping("config/express")
    @OperationName("1")
    public BaseRespVo configExpressPost(@RequestBody ConfigExpressVO configExpressVO) throws IllegalAccessException {
       adminConfigService.configExpressPost(configExpressVO);
        return BaseRespVo.ok(null);
    }


    /**
     * http://localhost:8083/admin/config/order
     * 订单配置
     *
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/20 14:02
     */
    @RequiresPermissions("admin:config:order:list")
    @GetMapping("config/order")
    @OperationName("1")
    public BaseRespVo configOrder() {
        ConfigOrderVO configOrderVO = adminConfigService.configOrder();

        return BaseRespVo.ok(configOrderVO);
    }

    @RequiresPermissions("admin:config:order:updateConfigs")
    @PostMapping("config/order")
    @OperationName("1")
    public BaseRespVo configOrderPost(@RequestBody ConfigOrderVO configOrderVO) throws IllegalAccessException {
        adminConfigService.configOrderPost(configOrderVO);
        return BaseRespVo.ok(null);
    }

    /**
     * http://localhost:8083/admin/config/wx
     * 小程序配置
     * @return com.example.springbott.bean.BaseRespVo
     * @author heheer
     * @since 2022/11/20 14:53
     */
    @RequiresPermissions("admin:config:wx:list")
    @GetMapping("config/wx")
    @OperationName("1")
    public BaseRespVo configWx(){
        ConfigWxVO configWxVO = adminConfigService.configWx();
        return BaseRespVo.ok(configWxVO);
    }

    @RequiresPermissions("admin:config:wx:updateConfigs")
    @PostMapping("config/wx")
    public BaseRespVo configWxPost(@RequestBody ConfigWxVO configWxVO) throws IllegalAccessException {
        adminConfigService.configWxPost(configWxVO);
        return BaseRespVo.ok(null);
    }




}
